package com.eazy.lkv2.web.controller.blog;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.eazy.lkv2.web.controller.BaseController;
import com.eazy.lkv2.web.entity.blog.Tag;
import com.eazy.lkv2.web.service.blog.TagService;

/**
 * 
 * @author jzx
 * 
 * @date 2016-11-08 10:28:40 星期二
 */
@Controller
@RequestMapping("/tag")
public class TagController extends BaseController<Object, String> {

	
	@Autowired
	private TagService tagService;

	@RequestMapping(value = "/list")
	public String list(HttpSession session, ModelMap map) {
		List<Tag> data = tagService.getTagList();
		map.put("data", data);
		return "/blog/admin/tag/tag_list";
	}

	@RequestMapping(value = "/addTag", method = RequestMethod.POST)
	public String addPartner(Tag tag) {
		tagService.create(tag);
		return "redirect:/tag/list";
	}

	@RequestMapping(value = "/editTag", method = RequestMethod.POST)
	public String editJump(Tag tag) {
		tagService.update(tag);
		return "redirect:/tag/list";
	}

	/**
	 * 跳转编辑页面
	 */
	@RequestMapping(value = "/editTag/{id}")
	public String editJump(ModelMap map, @PathVariable String id) {
		map.put("data", tagService.findById(Integer.valueOf(id)));
		return "/blog/admin/tag/tag_update";
	}

	/**
	 * 跳转新增页面
	 */
	@RequestMapping(value = "/addTag")
	public String addJump(ModelMap map) {
		return "/blog/admin/tag/tag_add";
	}

}
